package com.dg.cuckoo.admin.action.basicInformation.permissionSettings;

import com.dg.cuckoo.admin.service.JobFeaturesService;
import com.dg.cuckoo.core.BaseController;
import com.dg.cuckoo.core.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 基本资料-权限设置-岗位对功能
 */
@RestController
@RequestMapping("/basicInformation/permissionSettings/jobFeatures")
public class JobFeatures extends BaseController {

    @Autowired
    private JobFeaturesService service;

    /**
     * 页面显示
     */
    @PostMapping("select")
    public JsonResult<String> select(){
        String data = service.select();
        return new JsonResult<>(OK,data);
    }

    /**
     * 点击功能列表一级标签
     */
    @PostMapping("openOneLabel")
    public JsonResult<List<String>> openOneLabel(String name){
        List<String> data = service.openOneLabel(name);
        return new JsonResult<>(OK,data);
    }

    /**
     * 保存
     * @param jobName 岗位名称
     * @param featuress 功能列表
     * @return
     */
    @PostMapping("save")
    public JsonResult<Void> save(String jobName,List<String> featuress){
        service.save(jobName,featuress);
        return new JsonResult<>();
    }

    /**
     * 点击岗位名称显示功能列表
     * @param jobName 岗位名称
     * @return
     */
    @PostMapping("openJobName")
    public JsonResult<List<String>> openJobName(String jobName){
        List<String> data = service.openJobName(jobName);
        return new JsonResult<>(OK,data);
    }

    /**
     * 岗位删除
     * @param id 岗位id
     * @return
     */
    @PostMapping("delect")
    public JsonResult<Void> delect(String id){
        service.delect(id);
        return new JsonResult<>(OK);
    }

}
